package com.example.springboot1.mapper;

import com.example.springboot1.pojo.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface UserMapper {
    @Select("select * from user where id = #{id}")
    User getUserById(Integer id);

    //分页
    @Select("select * from user limit #{pageNum},#{pageSize}")
    List<User> selectPage(Integer pageNum, Integer pageSize);

    @Insert("insert into user (username,userpass,sex,age,phonenum,address,email) " +
            "value (#{username},#{userpass},#{sex},#{age},#{phonenum},#{address},#{email})")
    int InsertUser (User user);

    @Update("update user set username = #{username},userpass = #{userpass},sex = #{sex}," +
            "age = #{age},phonenum = #{phonenum},address = #{address},email = #{email} where id = #{id}")
    int updateUser (User user);

    @Delete("delete from user where id = #{id}")
    int deleteUser (Integer id);
}
